function [fdata]=smooth2(data,windowSize)


if size(data,1)==1
    data=[data(1)*ones(1,round(windowSize/2)) data data(end)*ones(1,round(windowSize/2))];
else
    data=[data(1)*ones(round(windowSize/2),1); data; data(end)*ones(round(windowSize/2),1)];
end

fdata=filter(ones(1,windowSize)/windowSize,1,data);
fdata=fdata(windowSize+1:end);


